/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: nu uc
 * License Type: Evaluation
 */
package org.testis.orm.classes;

import org.orm.*;

public class T_test_labelpairs {
    public T_test_labelpairs() {
    }

    public boolean save() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .saveObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean delete() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .deleteObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean refresh() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().refresh(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean evict() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().evict(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate() throws PersistentException {
	try {
	    if (getTestCase() != null) {
		getTestCase().t_test_labelpairs.remove(this);
	    }

	    if (getTestStep() != null) {
		getTestStep().t_test_labelpairs.remove(this);
	    }

	    if (getDataObject() != null) {
		getDataObject().t_test_labelpairs.remove(this);
	    }

	    return delete();
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate(org.orm.PersistentSession session)
	    throws PersistentException {
	try {
	    if (getTestCase() != null) {
		getTestCase().t_test_labelpairs.remove(this);
	    }

	    if (getTestStep() != null) {
		getTestStep().t_test_labelpairs.remove(this);
	    }

	    if (getDataObject() != null) {
		getDataObject().t_test_labelpairs.remove(this);
	    }

	    try {
		session.delete(this);
		return true;
	    } catch (Exception e) {
		return false;
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    private void this_setOwner(Object owner, int key) {
	if (key == org.testis.orm.manager.ORMConstants.KEY_T_TEST_LABELPAIRS_TESTCASE) {
	    this.TestCase = (org.testis.orm.classes.T_test_stepcontainer) owner;
	}

	else if (key == org.testis.orm.manager.ORMConstants.KEY_T_TEST_LABELPAIRS_TESTSTEP) {
	    this.TestStep = (org.testis.orm.classes.T_test_teststeps) owner;
	}

	else if (key == org.testis.orm.manager.ORMConstants.KEY_T_TEST_LABELPAIRS_DATAOBJECT) {
	    this.DataObject = (org.testis.orm.classes.T_test_dataobject) owner;
	}
    }

    org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
	public void setOwner(Object owner, int key) {
	    this_setOwner(owner, key);
	}

    };

    private int id;

    private org.testis.orm.classes.T_test_stepcontainer TestCase;

    private int labelId;

    private org.testis.orm.classes.T_test_teststeps TestStep;

    private org.testis.orm.classes.T_test_dataobject DataObject;

    private void setId(int value) {
	this.id = value;
    }

    public int getId() {
	return id;
    }

    public int getORMID() {
	return getId();
    }

    public void setLabelId(int value) {
	this.labelId = value;
    }

    public int getLabelId() {
	return labelId;
    }

    public void setTestCase(
	    org.testis.orm.classes.T_test_stepcontainer value) {
	if (TestCase != null) {
	    TestCase.t_test_labelpairs.remove(this);
	}
	if (value != null) {
	    value.t_test_labelpairs.add(this);
	}
    }

    public org.testis.orm.classes.T_test_stepcontainer getTestCase() {
	return TestCase;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_TestCase(
	    org.testis.orm.classes.T_test_stepcontainer value) {
	this.TestCase = value;
    }

    private org.testis.orm.classes.T_test_stepcontainer getORM_TestCase() {
	return TestCase;
    }

    public void setTestStep(org.testis.orm.classes.T_test_teststeps value) {
	if (TestStep != null) {
	    TestStep.t_test_labelpairs.remove(this);
	}
	if (value != null) {
	    value.t_test_labelpairs.add(this);
	}
    }

    public org.testis.orm.classes.T_test_teststeps getTestStep() {
	return TestStep;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_TestStep(
	    org.testis.orm.classes.T_test_teststeps value) {
	this.TestStep = value;
    }

    private org.testis.orm.classes.T_test_teststeps getORM_TestStep() {
	return TestStep;
    }

    public void setDataObject(
	    org.testis.orm.classes.T_test_dataobject value) {
	if (DataObject != null) {
	    DataObject.t_test_labelpairs.remove(this);
	}
	if (value != null) {
	    value.t_test_labelpairs.add(this);
	}
    }

    public org.testis.orm.classes.T_test_dataobject getDataObject() {
	return DataObject;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_DataObject(
	    org.testis.orm.classes.T_test_dataobject value) {
	this.DataObject = value;
    }

    private org.testis.orm.classes.T_test_dataobject getORM_DataObject() {
	return DataObject;
    }

    public String toString() {
	return toString(false);
    }

    public String toString(boolean idOnly) {
	if (idOnly) {
	    return String.valueOf(getId());
	} else {
	    StringBuffer sb = new StringBuffer();
	    sb.append("T_test_labelpairs[ ");
	    sb.append("Id=").append(getId()).append(" ");
	    if (getTestCase() != null)
		sb.append("TestCase.Persist_ID=")
			.append(getTestCase().toString(true)).append(" ");
	    else
		sb.append("TestCase=null ");
	    sb.append("LabelId=").append(getLabelId()).append(" ");
	    if (getTestStep() != null)
		sb.append("TestStep.Persist_ID=")
			.append(getTestStep().toString(true)).append(" ");
	    else
		sb.append("TestStep=null ");
	    if (getDataObject() != null)
		sb.append("DataObject.Persist_ID=")
			.append(getDataObject().toString(true)).append(" ");
	    else
		sb.append("DataObject=null ");
	    sb.append("]");
	    return sb.toString();
	}
    }

}
